#include "tree.h"

bool start( char *fn )
{
	CUTextFile file( fn, "r" );
	if( file.IsOpen() == false )	return false;

	int now_line=0;
	int num_rule=0;
	int num_reorder=0;
	int num_best=0;
	while(1)	{
		CUString line;
		if( file.ReadLine( line ) == false ) break;
		now_line++;

		if( line.GetAt(0) == '#' )	continue;

		CUStringList ls;
		ls.TokenizeByChar( line, "\t", false );
		int s = ls.GetSize();

		CUString reord = ls.GetAt(s-2);
		if( reord == "O" )	num_reorder++;

		CUString best = ls.GetAt(s-1);
		if( best == "O" )	num_best++;

		num_rule++;

	}

	fprintf( stdout, "num_rule:\t%d\n", num_rule );
	fprintf( stdout, "num_reorder:\t%d\n", num_reorder );
	fprintf( stdout, "num_best:\t%d\n", num_best );


	return true;
}


int main( int argc, char *argv[] )
{
	if( argc != 2 )	{
		fprintf( stderr, "usage: rulestat rule-file\n" );
		return 1;
	}

	if( start( argv[1] ) == false )	{
		return 1;
	}

	return 0;
}


